//
//  XMGShopCell.m
//  04-瀑布流
//
//  Created by 许卫星 on 16/12/14.
//  Copyright © 2016年 许卫星. All rights reserved.
//

#import "XWXShopCell.h"
#import "XWXShop.h"
#import "UIImageView+WebCache.h"

@interface XWXShopCell()
@property (strong, nonatomic)  UIImageView *imageView;
@property (strong, nonatomic)  UILabel *priceLabel;
@end

@implementation XWXShopCell

- (UIImageView *)imageView
{
    if (_imageView == nil) {
        _imageView = [[UIImageView alloc] init];
        _imageView.backgroundColor = [UIColor greenColor];
        _imageView.contentMode = UIViewContentModeScaleAspectFit;
        [self addSubview:_imageView];
    }
    return _imageView;
}

- (UILabel *)priceLabel
{
    if (_priceLabel == nil) {
        _priceLabel = [[UILabel alloc] init];
        _priceLabel.backgroundColor = [UIColor grayColor];
        _priceLabel.font = [UIFont systemFontOfSize:16];
        _priceLabel.textColor = [UIColor whiteColor];
        [self addSubview:_priceLabel];
    }
    return _priceLabel;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 30);
    _priceLabel.frame = CGRectMake(0, self.frame.size.height - 30, self.frame.size.width, 30);
}

- (void)setShop:(XWXShop *)shop
{
    _shop = shop;
    
    // 1.图片
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:shop.img] placeholderImage:[UIImage imageNamed:@"loading"]];
    
    // 2.价格
    self.priceLabel.text = shop.price;
}
@end
